<%@page import="java.sql.*" %>
<%@page import="java.sql.PreparedStatement" %>
<%@page import="java.sql.ResultSet" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
 <link rel="stylesheet" href="style/adminterface.css">
 <script>
 //查询用户窗口
 function update(){
     var x=document.getElementById("exit");
     var update=document.querySelector('.update');
       update.removeAttribute('hidden'); 
     //关闭按钮
     x.onclick=function(){
    	 update.setAttribute('hidden',"");
     };  
 }


  //添加用户窗口
 function add(){
     var x=document.getElementById("exit3");
     var add=document.querySelector('.add');
       add.removeAttribute('hidden'); 
     
     //关闭按钮
     x.onclick=function(){
    	 add.setAttribute('hidden',"");
     };  
 }
  
 onload=function(){
	    var fhjg=document.getElementById('fhjg').innerHTML;
	 
	    if(fhjg!=""){
	        alert(fhjg);
	        }
	    
	}
 function del(){
	 return confirm("您确定要删除吗？");
 }

 
 </script>
<title>管理员界面</title>
</head>
<body>

<!-----------导入hread.jsp--------------->
<%@include file="hread.jsp" %>

<!------------中间-->
<div class=one>
 <font color=red  id='fhjg' hidden>${fhjg}</font>
<div class=one-top><p>用户管理</p></div>

<!-----------用户列表-->
<div class=one-content>
    <table border=1>
        <tr>
            <th>用户id</th>
            <th>用户姓名</th>
            <th>用户邮箱</th>
            <th>操作</th>
        </tr>
 
        <!---------循环数据-->
<c:forEach var="user" items="${userList}">
        <tr>
            <td>${user.id}</td>
            <td>${user.user_name}</td>
            <td>${user.email}</td>
            <td><a href="updateUser.jsp?u_id=${user.id}&u_name=${user.user_name}&u_email=${user.email}"><button>修改</button></a><a onclick="return del()" href="admServlet.do?operation=delete&u_id=${user.id}"><button id=btn>删除</button></a></td>
  
        </tr>
</c:forEach>

    </table>
    
   <div class=ann><button class=btn3 onclick="update()">查询用户</button><button class=btn4 onclick="add()">添加用户</button></div>
   <!------添加框-->
             <div class=add hidden>
                <form action="admServlet.do?operation=add" method="post">
                    <h4>添加用户</h4>
                    用&nbsp;&nbsp;户&nbsp;名：<input type=text id=srk name=username size=20 required ></br>
                    登录密码：<input type="password" id=srk name=password size=20 required ></br>
                    用户邮箱：<input type="email" id=srk name=email size=20 required></br>
                    <input type="submit" value="添加" id=submit>
                    <button id=exit3>关闭</button>
                </form>
               
            </div>
            <!-- --------查询用户窗口 -->
            <div class=update hidden>
                <form action="admServlet.do?operation=select" method="post">
                    <h4>查询用户</h4>
                    请输入查询的用户名：<input type=text id=srk name=username size=20 required placeholder="请输入要查询的用户名"></br>
                    <input type="submit" value="查询" id=submit>
               <button id=exit>关闭</button>
                </form>               
            </div>
            
</div>
</div>

</body>
</html>